<template>
  <div class="viewport">
    <div class="top">
      <div class="line">
        <p>{{ userName }}</p>
        <span class="tip">{{ tel }}</span>
      </div>
    </div>

    <div class="bot">
      <ul>
        <li @click="goTO('myDate')">
          <span class="img">
            <img src="@/assets/iconImg/date.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 我的积分 </span>
            <span class="i"> > </span>
          </div>
        </li>
        <li @click="goTO('myCollect')">
          <span class="img">
            <img src="@/assets/iconImg/heart.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 我的收藏 </span>
            <span class="i">
              <span class="num"></span>
              >
            </span>
          </div>
        </li>

        <li @click="goTO('myRecommend')">
          <span class="img">
            <img src="@/assets/iconImg/good.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 我的推荐 </span>
            <span class="i">
              <span class="num"></span>
              >
            </span>
          </div>
        </li>

        <li @click="goTO('recommendMe')">
          <span class="img">
            <img src="@/assets/iconImg/paper.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 推荐向我 </span>
            <span class="i">
              <span class="num"></span>
              >
            </span>
          </div>
        </li>

        <li @click="goTO('opionion')" v-show="false">
          <span class="img">
            <img src="@/assets/iconImg/email.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 意见反馈 </span>
            <span class="i"> > </span>
          </div>
        </li>

        <li @click="goTO('form')">
          <span class="img">
            <img class="changeIcon" src="@/assets/iconImg/set.png" alt="" />
          </span>
          <div class="content">
            <span class="font"> 我的个人信息 </span>
            <span class="i"> > </span>
          </div>
        </li>
      </ul>
    </div>
    <div class="tclogin">
      <mt-button
        size="normal" 
        class="mint-button mint-button--danger mint-button--large changeLogin"
        @click="loginoff()"
        type="danger"
        >退出登录</mt-button
      >
    </div>
  </div>
</template>

<script> 
import { LogOut } from "../../api/personalcenter";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      userName: JSON.parse(window.localStorage.userInfo).RealName,
      tel: JSON.parse(window.localStorage.userInfo).mobile,
    };
  }, 
  computed: {
  },  
  mounted() {  
    // 实时更新数据   
  },
  activated() { 
    this.userName = JSON.parse(window.localStorage.userInfo).RealName;
    this.tel = JSON.parse(window.localStorage.userInfo).mobile;
  },
  methods: {  
    goTO(className) {
      this.$router.push("/" + className);
    },
    loginoff() {
      LogOut().then(res=>{
        localStorage.removeItem("userInfo");
        window.localStorage.removeItem("token");
        Toast({
          message:
           res.data.message,
          position: "center",
          duration: 1000,
        });
        this.$router.push("/login"); 
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.viewport {
  width: 100%;
  overflow-x: hidden; 
  min-height: 100vh;
  background-color: #ecf3f9;
  .top {
    width: 100%;
    height: 120px;
    background: #fff;
    position: relative;  
    background-image: url(../../assets/iconImg/personBackground.jpeg);
    background-size: 100%;
    .line {
      padding: 5px 40px;
      position: absolute;
      left: 0;
      top: 45%;
      transform: translateY(-50%);
      min-width: 50%;  
      max-width: 100%;
      background:#fff;
      opacity: 0.8;
      box-sizing: border-box;  
      border-radius: 0 10px 10px 0;
      p {
        font-size: 18px;
        font-weight: bold;
        padding: 0;
        margin: 0;
        margin-bottom: 5px;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .tip {
        display: inline-block;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #808080;
      }
    }
  }
  .bot {
    margin-top: 20px;
    width: 100%;
    background: #fff;
    ul {
      width: 100%;
      list-style: none;
      padding: 0;
      li {
        width: 100%;
        height:60px;
        line-height: 60px;
        padding: 0 10px;
        .img {
          display: inline-block;
          width: 32px;
          height: 32px;
          vertical-align: middle;
          img {
            width: 100%;
            height: 100%;
            margin-bottom:6px;
          } 
         
        }
        .content {
          display: inline-block;
          height: 100%;
          vertical-align: middle;
          width: calc(100% - 60px);
          border-bottom: 1px solid #ddd;
          position: relative;

          .font {
            width: calc(100% - 50px);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: inline-block;
          }
          .i {
            position: absolute;
            right: 0;
            color: #989898;
            font-size: 20px;
            .num {
              font-size: 14px;
              vertical-align: top;
            }
          } 
        
        }
      }

      li:nth-child(2) {
        img {
          margin-left: 5px;
          width: 24px;
          height: 24px;
        }
      }

      li:nth-child(3) {
        img {
          margin-left: 6px;
          width: 24px;
          height: 24px;
        }
      }
      li:nth-child(5) {
        img {
          margin-left: 6px;
          width: 24px;
          height: 24px;
        }
      }
      li:nth-child(6) {
        img {
          margin-left: 6px;
          width: 24px;
          height: 24px;
        }
      }
    }
  } 
  .tclogin {
    width:100%;
    margin-top: 60px; 
    text-align: center;
    .changeLogin {
      width:250px;
      border-radius: 10px;
    }
  } 
}
</style>